﻿using System.Xml.Linq;

namespace Phoenix.Xna.Framework.Serialization
{
    public interface ISerializer
    {
        /// <summary>
        /// Creates a xml model of the instance and all of it's decendents based on the SerializableCollectionAttribute & the DefaultValueAttribute.
        /// </summary>
        /// <param name="instance">The object model to be serialized.</param>
        /// <returns>The string serialized form of the object model.</returns>
        string Serialize(object instance);

        /// <summary>
        /// Creates a xml model of the instance and all of it's decendents based on the SerializableCollectionAttribute & the DefaultValueAttribute.
        /// </summary>
        /// <param name="instance">The object model to be serialized.</param>
        /// <returns>The XElement serialized form of the object model.</returns>
        XElement SerializeAsXElement(object instance);

        /// <summary>
        /// Creates a fully instantiated object model defined by the the xml model.
        /// </summary>
        /// <param name="xml">The persisted xml model</param>
        /// <returns>The fully instantiated object model</returns>
        object Deserialize(string xml);

        /// <summary>
        /// Creates a fully instantiated object model defined by the the xml model.
        /// </summary>
        /// <param name="xml">The persisted xml model</param>
        /// <returns>The fully instantiated object model</returns>
        object Deserialize(XElement element);
    }
}
